<?php
/**
 * HasCoinState Class
 * 已经投币的状态
 *
 */

class HasCoinState implements State {

	public $gumballMachine = null;

	public function __construct($gumballMachine)
	{
		$this->gumballMachine = $gumballMachine;
	}

	// 投币
	public function insertCoin()
	{
		echo "You can't insert another quarter.\n";
	}	

	// 退币
	public function ejectCoin()
	{
		echo "Coin returned.\n";
		$this->gumballMachine->setState($this->gumballMachine->getNoCoinState());
	}	

	// 转动摇柄
	public function turnCrank()
	{
		echo "You turned...\n";
		$this->gumballMachine->setState($this->gumballMachine->getSoldState());
	}

	// 发糖果
	public function dispense()
	{
		echo "No gumball dispensed.\n";
	}

	public function show()
	{
		return "waiting for turn of crank.\n";
	}

}